//
//  NetworkRetryModel.swift
//  SwiftNetwork
//
//  Created by 万孟超 on 2022/1/12.
//

import UIKit

class NetworkRetryModel: NSObject {
    
    private let enginePoint : String
    private let networkRequest : NetworkBaseRequest
    private let successBlock : NetworkCompleteBlock?
    private let errorBlock : NetworkErrorBlock?
    private let progressBlock : NetworkProgressBlock?
    
    init(enginePoint : String,
         request : NetworkBaseRequest,
         isTimeOutRetry : Bool = false,
         completeBlock : NetworkCompleteBlock?,
         failBlock : NetworkErrorBlock?,
         progress : NetworkProgressBlock?) {
        self.enginePoint = enginePoint
        self.networkRequest = request
        self.successBlock = completeBlock
        self.errorBlock = failBlock
        self.progressBlock = progress
        super.init()
        networkRequest.isTimeOutRetry = isTimeOutRetry
    }
    
    func networkRetry() {
        NetworkManager.POST(withRequest: networkRequest, wihEnginePoint: enginePoint, withProgressBlock: progressBlock, withCompleteBlock: successBlock, withErrorBlock: errorBlock)
    }
}
